import requests
class TestTPshop:
    def setup(self):
        self.session = requests.session()
    def test01_register_success(self):
        url_code = "http://hmshop-test.itheima.net/index.php?m=Home&c=User&a=verify&type=user_reg&r=0.20441862468864902"
        self.response = self.session.get(url=url_code)

        url = "http://hmshop-test.itheima.net/Home/User/reg.html"
        register_data = {
            "username":"65756856780",
            "verify_code":"8888",
            "password":"君乐666",
            "password2":"君乐666"
            # "invite":"15689999901"
        }
        response = self.session.post(url=url,data=register_data)
        print(response.json())

        assert response.status_code == 200
        assert response.json().get("status") == 1
        assert response.json().get("msg") == "注册成功"

    def test01_phoneNumberIsEmpty(self):
        url_code = "http://hmshop-test.itheima.net/index.php?m=Home&c=User&a=verify&type=user_reg&r=0.20441862468864902"
        self.response = self.session.get(url=url_code)

        url = "http://hmshop-test.itheima.net/Home/User/reg.html"
        register_data = {
            "username":"",
            "verify_code":"8888",
            "password":"abc_123",
            "password2":"abc_123"
            # "invite":"15689999901"
        }
        response = self.session.post(url=url,data=register_data)
        print(response.json())

        assert response.status_code == 200
        assert response.json().get("status") == -1
        assert response.json().get("msg") == "请用手机号或邮箱注册"

    def test01_passwordIsEmpty(self):
        url_code = "http://hmshop-test.itheima.net/index.php?m=Home&c=User&a=verify&type=user_reg&r=0.20441862468864902"
        self.response = self.session.get(url=url_code)

        url = "http://hmshop-test.itheima.net/Home/User/reg.html"
        register_data = {
            "username":"65756856780",
            "verify_code":"8888",
            "password":"",
            "password2":"abc_123"
            # "invite":"15689999901"
        }
        response = self.session.post(url=url,data=register_data)
        print(response.json())

        assert response.status_code == 200
        assert response.json().get("status") == -1
        assert response.json().get("msg") == "密码不能为空"